package com.chhh.cranelease.controller.businessmanage;

import com.chhh.cranelease.entity.Parts;
import com.chhh.cranelease.model.ResponseCode;
import com.chhh.cranelease.service.BusinessManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("parts")
public class PartsController {

    @Autowired
    private BusinessManageService businessManageService;


    private ResponseCode responseCode = new ResponseCode();

    @RequestMapping("selectAllParts")
    public List<Parts> selectAllParts(String p_date, String p_num, String p_des){
        return businessManageService.selectAllParts(p_date,p_des,p_num);
    }
    @RequestMapping("insertParts")
    public ResponseCode insertParts(Parts parts){
        Integer part = businessManageService.insertParts(parts);
        responseCode.setErrorCode(0);
        responseCode.setStatus("你插入了"+part+"条数据");
        return responseCode;
    }
    @RequestMapping("updateParts")
    public ResponseCode updateParts(Parts parts){
        Integer part = businessManageService.updateParts(parts);
        responseCode.setErrorCode(0);
        responseCode.setStatus("你更新了"+part+"条数据");
        return responseCode;
    }
    @RequestMapping(value = "deleteParts")
    public ResponseCode deleteParts(Integer[] p_id){
     Integer partNum = businessManageService.deleteParts(p_id);
        responseCode.setErrorCode(0);
        responseCode.setStatus("你已经删除"+partNum+"条数据");
        return responseCode;
    }
}
